package com.grace.storage.enums.properties;

import com.grace.common.enums.SysConfigGroups;
import com.grace.common.properties.PropertyEnum;

public enum StorageConfigProperties implements PropertyEnum {

    STORAGE_CONFIG_GROUP(SysConfigGroups.STORAGE_CONFIG.getValue(), String.class, SysConfigGroups.STORAGE_CONFIG.getValue()),
    STORAGE_USED("sys.storage.used", String.class, "native"),
    /* 储存配置前缀 */
    STORAGE_PREFIX("sys.storage.", String.class, ""),
    /* 本地配置前缀 */
    STORAGE_PREFIX_NATIVE("sys.storage.native.", String.class, ""),
    /* 七牛配置前缀 */
    STORAGE_PREFIX_QN("sys.storage.qiniu.", String.class, ""),
    /* 阿里储存配置前缀 */
    STORAGE_PREFIX_AL("sys.storage.aliyun.", String.class, ""),
    /* up储存配置前缀 */
    STORAGE_PREFIX_UP("sys.storage.upyun.", String.class, ""),
    // 允许图片
    STORAGE_IMAGE_MAX_SIZE("sys.storage.image.maxSize", Long.class, "1024"),
    // 允许文档
    STORAGE_DOCUMENT_MAX_SIZE("sys.storage.document.maxSize", Long.class, "1024"),
    // 允许压缩
    STORAGE_COMPRESS_MAX_SIZE("sys.storage.compress.maxSize", Long.class, "1024"),
    // 允许视频
    STORAGE_VIDEO_MAX_SIZE("sys.storage.video.maxSize", Long.class, "1024"),
    // 允许音频
    STORAGE_MUSIC_MAX_SIZE("sys.storage.music.maxSize", Long.class, "1024"),
    // 允许原文件最长文件名
    STORAGE_FILE_NAME_MAX_LENGTH("sys.storage.max.length", Integer.class, "100"),
    // 支持文件类型 图片 文档 默认为空允许所有
    STORAGE_FILE_SUPPORT_TYPE("sys.storage.support.type", String.class, ""),
    // 文件名中文是否转换为拼音大写第一个字符
    STORAGE_FILE_NAME_ZH_PY("sys.storage.zh.py", Boolean.class, "true");

    private final String value;

    private final Class<?> type;

    private final String defaultValue;

    StorageConfigProperties(String value, Class<?> type, String defaultValue) {
        this.defaultValue = defaultValue;
        if (!PropertyEnum.isSupportedType(type)) {
            throw new IllegalArgumentException("Unsupported web property type: " + type);
        }

        this.value = value;
        this.type = type;
    }

    @Override
    public Class<?> getType() {
        return type;
    }

    @Override
    public String defaultValue() {
        return defaultValue;
    }

    @Override
    public String getValue() {
        return value;
    }

}
